import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home'
import Friends from '../views/Friends'
import Search from '../views/Search'
import Cart from '../views/Cart'
import NoFoundPage from '../views/NoFoundPage'
import Main from '../views/Main'
import NewsList from '../views/news/NewsList'
import NewsInfo from '../views/news/NewsInfo'
import PhotoList from '../views/photos/PhotoList'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: Main,
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: Home,
        meta: {
          title: '首页'
        }
      },
      {
        path: '/friends',
        component: Friends,
        meta: {
          title: '会员'
        }
      },
      {
        path: '/search',
        component: Search,
        meta: {
          title: '搜索'
        }
      },
      {
        path: '/cart',
        component: Cart,
        meta: {
          title: '购物车'
        }
      },
      {
        path: '/home/newslist',
        component: NewsList,
        meta: {
          title: '新闻列表'
        }
      },
      {
        path: '/home/newsinfo/:id',
        component: NewsInfo,
        meta: {
          title: '新闻详情'
        },
        props: true
      },
      {
        path: '/home/photolist',
        component: PhotoList,
        meta: {
          title: '图片列表'
        }
      }
    ]
  },
  {
    path: '*',
    component: NoFoundPage
  }
]

const router = new VueRouter({
  routes
})

export default router
